#ifndef WEAVEINSTRUCTIONLOGIC_H
#define WEAVEINSTRUCTIONLOGIC_H
#include "ioinstruction.h"
#include "programset.h"
#include "instructionEnum.h"
#include "robotio.h"
#include "GeneralDefine.h"
#include "mccontrollerthread.h"
class ProgramEngine;


class WeaveInstructionLogic
{
public:
    WeaveInstructionLogic(QString configFilePathIn, int robotIdIn, ProgramSet* programSetIn, RobotIo* ioControllerIn,
                          ProgramEngine* programEngineIn, McControllerThread *programMcControllerIn);
public:
    E_PROGRAM_LOOP_RESULT startWeave(int programNum,WeaveInstruction weaveInstruct);
    E_PROGRAM_LOOP_RESULT startWeaveEnd(int programNum,WeaveEndInstruction weaveEndInstruct);
    int reset();
    int getWeaveMotionConditionInfo(std::vector<struct WeaveMotionCondition> &infoOut);
    int setWeaveMotionConditionInfo(struct WeaveMotionCondition infoIn);

private:
    int writeWeaveMotionConditionInfo(QString filePathIn,WeaveMotionCondition weldCondition);
    int readConfigFile(QString filePathIn, QString &readComent);
    void addMsg( int messageLevel,
                 std::string componentName,
                 std::string messageType,
                 int messageCode,
                 int robotId,
                 int parameter1 = 0,
                 int parameter2 = 0,
                 int parameter3 = 0,
                 int parameter4 = 0,
                 QString message= "");
private:
    int robotId;
    ProgramSet* programSet;
    RobotIo* ioController;
    ProgramEngine* programEngine;
    QString configFilePath;
    McControllerThread *programMcController;

    std::vector<WeaveMotionCondition> weaveConditionList;

    QMutex usingMutex;

    double velRatio;
    double accRatio;
};

#endif // WEAVEINSTRUCTIONLOGIC_H
